from selenium.webdriver.common.by import By
import time
from unit__003.unit_06.base import Base
from unit__003.unit_06.page_login import Page_login


class Page_search(Page_login):
    # 页面元素定位

    # 1.搜索框输入-水瓶
    search_loc = (By.XPATH, '//*[@id="searchForm"]/div[1]/input')

    # 2.点击商品
    sp_loc = (By.XPATH, '/html/body/div[5]/div[2]/div[2]/div[1]/ul/li/div[1]/span/a/img')

    # 3.点击立即购买 id="buy-cart"
    buy_loc = (By.ID, 'buy-cart')

    # 4.点击下一步
    next_loc=(By.ID,'order-button')
    # 断言

    # 封装元素的操作方法
    # 1.输入框输入-水瓶
    def search(self):
        self.send_keys(self.search_loc, '水瓶')

    # 回车事件
    def enters(self):
        self.Enters(self.search_loc)

    # 2.点击商品
    def sahngping(self):
        self.click(self.sp_loc)

    # 3.点击立即购买
    def buy(self):
        self.click(self.buy_loc)

    # 4.点击下一步
    def next(self):
        self.click(self.next_loc)
